//
//  RBLocationManager.h
//  FD
//
//  Created by xiaofang wang on 2018/10/30.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN

//定位成功的回调 CLLocation
typedef void(^RBLocationComplectionBlock)(CLLocation *location);

//地理编码成功block回调
typedef void(^RBPlacemarkComplectionBlock)(CLPlacemark *placemark);

//定位失败的回调
typedef void(^RBLocationFailBlock)(NSError *error);

@interface RBLocationManager : NSObject
/**1.单例类*/
+ (RBLocationManager *)shareInstance;

/**2.申请定位权限
 需要在info.plist 中添加如下字段
 Privacy - Location When In Use Usage Description
 Privacy - Location Always Usage Description
 */
- (void)requestLocationPermission;

/**3.查看定位权限*/
- (BOOL)checkLocationPermission;


/**4.获取当前定位
 desiredAccurancy 定位精准度
 */
- (void)updateLocationWithDesiredAccurancy:(CLLocationAccuracy)desiredAccurancy complectionBlock:(RBLocationComplectionBlock)complection failureBlcok:(RBLocationFailBlock)failure;

/**5. 持续获取当前定位*/
- (void)keepUpdateLocationWithDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy distanceFilter:(CGFloat)distanceFilter complectionBlock:(RBLocationComplectionBlock)complection failBlock:(RBLocationFailBlock)failure;

/**6.后台持续定位*/
- (void)keepUpdateLocationInBackgroundWithDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy distanceFilter:(CGFloat)distanceFilter complectionBlock:(RBLocationComplectionBlock)complection failBlock:(RBLocationFailBlock)failure;

/**7.停止获取定位*/
- (void)stopUpdateLocation;

/**8.获取指南针信息*/
//- (void)

/**9.停止获取指南针信息*/

/**10.地理编码*/
- (void)geocodeAddressString:(NSString *)address complectionBlock:(RBPlacemarkComplectionBlock)complection failBlock:(RBLocationFailBlock)failure;

/**11.反地理编码*/
- (void)reverseGeocodeLocation:(CLLocation *)location complectionBlock:(RBPlacemarkComplectionBlock)complection failBlock:(RBLocationFailBlock)failure;
- (void)reverseGeocodeCoordinate:(CLLocationCoordinate2D)coordinate complectionBlock:(RBPlacemarkComplectionBlock)complection failBlock:(RBLocationFailBlock)failure;


/** 12. 后台定位低功耗设置，设置后，当定位超过该距离或超过该时间后才会去进行下一次定位，避免多次定位导致增加耗电量
 distance:距离(米)
 timeout: 超时时间(秒)
 */
- (void)delayUpdateLocationWithDistance:(CLLocationDistance)distance timeout:(NSTimeInterval)timeout;


/**13 取消低功耗设置*/
- (void)cancelDelayUpdateLocation;

/**14.计算两个坐标之间的距离 单位m*/
- (CLLocationDistance)calculateDistanceWithLoc1:(CLLocation *)loc1 loc2:(CLLocation *)loc2;

@end

NS_ASSUME_NONNULL_END
